import request from '@/utils/request'
import type { Admin, AdminForm, Role, RoleForm, PaginationResponse } from '@/types'

// 获取管理员列表
export const getAdminList = (params: any): Promise<PaginationResponse<Admin>> => {
  return request.get('/system/admins', { params })
}

// 创建管理员
export const createAdmin = (data: AdminForm): Promise<void> => {
  return request.post('/system/admins', data)
}

// 更新管理员
export const updateAdmin = (id: number, data: AdminForm): Promise<void> => {
  return request.put(`/system/admins/${id}`, data)
}

// 删除管理员
export const deleteAdmin = (id: number): Promise<void> => {
  return request.delete(`/system/admins/${id}`)
}

// 重置管理员密码
export const resetAdminPassword = (id: number, password: string): Promise<void> => {
  return request.put(`/system/admins/${id}/password`, { password })
}

// 获取角色列表
export const getRoleList = (params: any): Promise<PaginationResponse<Role>> => {
  return request.get('/system/roles', { params })
}

// 创建角色
export const createRole = (data: RoleForm): Promise<void> => {
  return request.post('/system/roles', data)
}

// 更新角色
export const updateRole = (id: number, data: RoleForm): Promise<void> => {
  return request.put(`/system/roles/${id}`, data)
}

// 删除角色
export const deleteRole = (id: number): Promise<void> => {
  return request.delete(`/system/roles/${id}`)
}

// 获取权限列表
export const getPermissionList = (): Promise<any> => {
  return request.get('/system/permissions')
}

// 获取系统设置
export const getSystemSettings = (): Promise<any> => {
  return request.get('/system/settings')
}

// 更新系统设置
export const updateSystemSettings = (data: any): Promise<void> => {
  return request.put('/system/settings', data)
}

// 获取操作日志
export const getOperationLogs = (params: any): Promise<any> => {
  return request.get('/system/logs', { params })
}

// 获取系统监控数据
export const getSystemMonitor = (): Promise<any> => {
  return request.get('/system/monitor')
}